package cn.com.xinjinfu.pdoulcProduct.utils;

import android.content.res.Resources;
public class PersonUtils {
	public static final String[] fuxing=new String[]{"欧阳","太史","端木","上官","司马","东方","独孤","南宫","万俟","闻人","夏侯","诸葛","尉迟","公羊","赫连","澹台","皇甫","宗政","濮阳","公冶","太叔","申屠","公孙","慕容","仲孙","钟离","长孙","宇文","司徒","鲜于","司空","闾丘","子车","亓官","司寇","巫马","公西","颛孙","壤驷","公良","漆雕","乐正","宰父","谷梁","拓跋","夹谷","轩辕","令狐","段干","百里","呼延","东郭","南门","羊舌","微生","公户","公玉","公仪","梁丘","公仲","公上","公门","公山","公坚","左丘","公伯","西门","公祖","第五","公乘","贯丘","公皙","南荣","东里","东宫","仲长","子书","子桑","即墨","达奚","褚师"};
	/**
	 * 截取用户名
	 * @param username
	 * @return 经过截取并添加***后的字符串
	 */
	public static String getName(String username){  
		if(NewUtil.isnull(username)){
			return "";
		}
		for(String xing:fuxing){
			if(xing.equals(username.substring(0, 2))){
				return username.substring(0, 2)+"*";
			}
		}
		return username.charAt(0)+"**";
	}
	public static String getSex(String username,String num){
		username=getName(username);
		if(username.contains("*")){
			username=username.replaceAll("\\*","");
		}
		int index=0;
		if(num.length()==15){
			index=num.charAt(13);
		}
		if(num.length()==18){
			index=num.charAt(16);
		}
		switch (index%2) {
		case 0:
			username+="女士";
			break;
		default:
			username+="先生";
			break;
		}
		return username;
	}
	/**
	 * 截取用户名
	 * @return 经过截取并添加***后的字符串
	 */
	public static String getIdentity(String identity){
		if(identity==null){
			return "";
		}
		if(identity.length()==18){
			identity=identity.replace(identity.substring(4,16),"******");
		}else if(identity.length()==15){
			identity=identity.replace(identity.substring(4,13),"******");
		}
		return identity;
	}




	public String getString(Resources res,int id)
	{
		return res.getString(id);
	}

}
